package com.yyge.kt.ui.activity

import android.annotation.SuppressLint
import android.content.Intent
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.core.view.ViewCompat
import androidx.core.view.ViewPropertyAnimatorListener
import androidx.core.view.WindowInsetsCompat
import com.yyge.base.BaseActivity
import com.yyge.kt.databinding.ActivitySplashBinding

@SuppressLint("CustomSplashScreen")
class SplashActivity : BaseActivity(), ViewPropertyAnimatorListener {

     // lateinit 延迟初始化非空属性
    @SuppressLint("StaticFieldLeak")
    lateinit var binding: ActivitySplashBinding;

    override fun getLayoutId(): View {
        binding = ActivitySplashBinding.inflate(layoutInflater)
        return binding.root;
    }

    override fun initUI() {
        super.initUI()
        ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }
  override fun initListener(){
     print("监听器")
  }

    override fun initData() {
        super.initData()
        ViewCompat.animate(binding.imageView).scaleX(1.0f).scaleY(1.0f)
            .setListener(this)
            .setDuration(2000)
    }

    override fun onAnimationStart(view: View) {

    }

    override fun onAnimationEnd(view: View) {
      //动画结束后进入主界面
      // 创建一个 Intent 对象，指定当前上下文和目标 Activity
      val intent = Intent(this, MainActivity::class.java)
      startActivity(intent)
      // 通过 startActivity() 方法启动 SecondActivity
    }

    override fun onAnimationCancel(view: View) {

    }
}